package com.zifeng.feign.fallback;

import com.zifeng.common.R;
import com.zifeng.exception.BizException;
import com.zifeng.exception.ErrorEnum;
import com.zifeng.feign.BlockFeignClient;
import com.zifeng.pojo.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import static com.zifeng.exception.ErrorCodeAndMsg.*;

@Slf4j
@Component
public class BlockFeignClientFallback implements BlockFeignClient {
    @Override
    public R mine(Order order) {
        log.error("调用区块链服务生成订单区块失败，订单：{}", order);
        return R.error(BLOCK_FEIGN_CREATE_FAIL_CODE, BLOCK_FEIGN_CREATE_FAIL_MSG)
                .put("error", new BizException(ErrorEnum.BLOCK_FEIGN_CREATE_FAIL));
    }
}
